/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.gui.controls;

import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.net.URI;
import javax.swing.JLabel;
import org.apache.log4j.Logger;

/**
 *
 * @author Administrator
 */
public class HelpLinkLabel extends JLabel {
    
    private static Logger logger = Logger.getLogger(HelpLinkLabel.class);
    
    public HelpLinkLabel() {
        super();

        this.setText("<html><span style='text-decoration:underline;'>Help</span></html>");
        this.addMouseListener(new MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent e) {
                myMouseClicked(e);
            }
            
            public void mouseEntered(java.awt.event.MouseEvent e) {
                HelpLinkLabel.this.setCursor(new Cursor(Cursor.HAND_CURSOR));
            }
        });
    }

    private void myMouseClicked(MouseEvent e) {
        try {
            //Workaround met URI om spatiebug met %20 op te lossen
            URI uri = new URI(getClass().getResource("/client/help/woordspelletjes.chm").getFile());
            Desktop.getDesktop().open(new File(uri.getPath()));
        } catch (Exception ex) {
            logger.error(ex.getMessage());
        }
    }
}
